package com.fce.boc.service;

import com.fce.boc.bean.ReturnMsg;
import com.fce.boc.exception.ErrorCodeAndMsg;
import com.fce.boc.mapper.BocTransactionMapper;
import com.fce.boc.bean.BocTransaction;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wenzhuo
 * @create 2023-10-13 2023/10/13
 */
@Service
public class BocTransactionService {

    @Resource
    private BocTransactionMapper bocTransactionMapper;

    public ReturnMsg getTransaction(Integer refKey){
        List<BocTransaction> list = bocTransactionMapper.getTransactionList(refKey);
        if(list.isEmpty()){
            return ReturnMsg.error(ErrorCodeAndMsg.DATA_NOT_EXIST);
        }

        return  ReturnMsg.success().setData(list);
    }

    public ReturnMsg addTransaction(BocTransaction transaction){
        if(bocTransactionMapper.addTransaction(transaction) <= 0){
            return ReturnMsg.error(ErrorCodeAndMsg.DATA_NOT_EXIST);
        }

        return  ReturnMsg.success();
    }



}
